﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace XGameLibrary
{
    public static class Utility
    {
        private static Texture2D simpleTexture;
        private static Texture2D InitSimpleTexture(GraphicsDevice graphicsDevice)
        {
            if (simpleTexture == null)
            {
                simpleTexture = new Texture2D(graphicsDevice, 1, 1, false, SurfaceFormat.Color);

                Int32[] pixel = { 0xFF }; // White. 0xFF is Red, 0xFF0000 is Blue
                simpleTexture.SetData<Int32>(pixel, 0, simpleTexture.Width * simpleTexture.Height);
            }
            return simpleTexture;
        }
        public static void DrawRectangle(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Rectangle rectangle, bool isFill)
        {
            if (isFill == true)
                spriteBatch.Draw(InitSimpleTexture(graphicsDevice), rectangle, Color.White);
            else
            {
                spriteBatch.Draw(InitSimpleTexture(graphicsDevice), new Rectangle(rectangle.Left, rectangle.Top, rectangle.Width, 1), Color.White);
                spriteBatch.Draw(InitSimpleTexture(graphicsDevice), new Rectangle(rectangle.Right, rectangle.Top, 1, rectangle.Height), Color.White);
                spriteBatch.Draw(InitSimpleTexture(graphicsDevice), new Rectangle(rectangle.Left, rectangle.Top, 1, rectangle.Height), Color.White);
                spriteBatch.Draw(InitSimpleTexture(graphicsDevice), new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, 1), Color.White);
            }
        }
    }
}
